<?php


/*
Author: QuangHuy - 22/06/2008
*Function to replace a operator in theory at paractice
*Parameter  string source
*Parameter 
*Parameter 
*Return a String, 
*/
function replaceMasterOne($tstr, $prefix = "master_bean::", $beginquote = "{", $endquote = "}")
{
	$mStr = $tstr;
	$subStr = "";
	$beginpos = strpos($mStr, $prefix, 0);

	if ($beginpos > 0) {
		$endpos = strpos($mStr, $endquote, $beginpos);
		$subStr = substr($mStr, $beginpos - 1, $endpos - $beginpos + 2); //lay duoc chuoi con bao gom ca {}
		$id_operator = substr($subStr, strlen($prefix) + 1 , strlen($subStr) - strlen($prefix) - 2); // 2 tuong trung cho {}
		$replaceStr = "document.getElementById('".$id_operator."').value";
		return str_replace($subStr, $replaceStr, $mStr, $count);
	}

	//return $mStr;
	
}



function replaceSubOne($tstr, $prefix = "sub_bean::", $beginquote = "{", $endquote = "}")
{
	$mStr = $tstr;
	$subStr = "";
	$beginpos = strpos($mStr, $prefix, 0);

	if ($beginpos > 0) {
		$endpos = strpos($mStr, $endquote, $beginpos);
		$subStr = substr($mStr, $beginpos - 1, $endpos - $beginpos + 2); //lay duoc chuoi con bao gom ca {}
		$id_operator = substr($subStr, strlen($prefix) + 1 , strlen($subStr) - strlen($prefix) - 2); // 2 tuong trung cho {}
		$replaceStr = "document.getElementById('".$id_operator."' + i).value";
		return str_replace($subStr, $replaceStr, $mStr, $count);
	}

	//return $mStr;
	
}

?>